
#include "transforms.inc"

#declare w = 35;
#declare h = 35;

camera {
   orthographic
   location <0, 6, -6>
   right <w/11, 0, 0>
   up <0, h/11, 0>            
   look_at <0, 1, 0>     
}     

                 
#declare finishBomb = finish {
    phong 1
    ambient 1 
    diffuse 1  
}               

#declare matBomb = texture {
  pigment { rgb <0, 1, 0> }
  finish { finishBomb }  
  normal {
    dents 1.5
    scale .3
  }
}      

#declare matBomb2 = texture {
  pigment { rgb <1, 0, 0> }
  finish { finishBomb }  
  normal {
    dents 2
    scale .3
  }
}      

#declare matWhite = texture {
  pigment { rgb <1, 1, 1> }
  finish { finishBomb }  
  normal {
    dents 2
    scale .3
  }
}

#declare matBlack = texture {
  pigment { rgb <.2, .2, .2> }
  finish { finishBomb }  
}

background { color rgb <1, 0, 1> }
global_settings { ambient_light color rgb <0.5, 0.5, 0.5> }



// default light
light_source { <+100, 1000, -1000> color .6 }      
//light_source { <-125.67, 2515.71, +3000> color .6 }                       

           
#if( clock >= .5 )           
#declare zf = clock-.75;
#else
#declare zf = clock-.25;
#end

#declare RR = 1.4 - .3*pow(zf,2);
    
#if (clock>=.25 & clock<.5)
#declare N = 12;
#else
#declare N = 5;
#end

#declare ang = <N*cos(clock*8*3.14), 0, N*sin(clock*8*3.14)>;


#declare matBanner = texture {
  pigment {
    image_map {
      tga "flammable.tga"
      map_type 2
      once
    }
  }
  finish { finishBomb }
  scale .6*2*RR
  translate <0,.4,0>
  rotate <0,-60,0>
  Rotate_Around_Trans(ang, <0, 1, 0>)
}      


/*
cylinder { <0,0.7,0> <0,1.3,0> RR+.01
  Rotate_Around_Trans(ang, <0, 1, 0>)
  material { texture { matBanner } }
} */

sphere { <0,1,0> RR+.01
  Rotate_Around_Trans(ang, <0, 1, 0>)
  material { texture { matBanner } }
}

#if (clock<.5)     

    #declare RB = RR/2.3;

    sphere { <0, 1, 0>, RR
      material { texture { matBomb } }
      Rotate_Around_Trans(ang, <0, 1, 0>)
    }
    
    //cylinder { <0, .9, 0> <0, 1.1, 0> RR
    //  material { texture { matBomb2 } } 
    //  Rotate_Around_Trans(ang, <0, 1, 0>)
    //}         
    

    cylinder { <0, .9+RR, 0> <0, 1+RR, 0> RB
      material { texture { matBomb2 } } 
      Rotate_Around_Trans(ang, <0, 1, 0>)
    }
    
#else
    
    #declare RB = RR*.5;
    #declare ramw = .15;

    difference {
        sphere { <0, 1, 0>, 1.05*RR }
        sphere { <0, 1, 0>, 0.95*RR }
        cylinder { <0, 1, 0>, <0,3,0> RB }
        box { <-4,-4,-4> <4,1.6,4> }
        cylinder { <0, 1, 0>, <0,2.3,0> RB*.9 }
        box { <-2,-3,-3> <-ramw,3,3> }
        box { <ramw,-3,-3> <2,3,3> }
        //cylinder { <0, 1, 0>, <0,3,0> RB }
        material { texture { matBlack } }
        Rotate_Around_Trans(ang, <0, 1, 0>)
    }
    
    difference {
        sphere { <0, 1, 0>, 1.05*RR }
        sphere { <0, 1, 0>, 0.95*RR }
        cylinder { <0, 1, 0>, <0,3,0> RB }
        box { <-4,-4,-4> <4,1.6,4> }
        cylinder { <0, 1, 0>, <0,2.3,0> RB*.9 }
        box { <-3,-3,-2> <3,3,-ramw> }
        box { <-3,-3,ramw> <3,3,2> }
        //cylinder { <0, 1, 0>, <0,3,0> RB }
        material { texture { matBlack } }
        Rotate_Around_Trans(ang, <0, 1, 0>)
    }
    
    difference {
        sphere { <0, 1, 0>, RR }
        box { <-1,1.9,-1> <1,3,1> }
        sphere { <0, 1, 0>, RR*.95 }
        //cylinder { <0, 1, 0>, <0,3,0> RB }
        material { texture { matBomb } }
        Rotate_Around_Trans(ang, <0, 1, 0>)
    }
    
    difference {
        sphere { <0, 1, 0>, RR*.95 }
        box { <-1,1.9,-1> <1,3,1> }
        //cylinder { <0, 1, 0>, <0,3,0> RB }
        material { texture { matBomb2 } }
        Rotate_Around_Trans(ang, <0, 1, 0>)
    }
    
    /*
    difference {
        cylinder { <0, 1, 0>, <0,2,0> RB }
        cylinder { <0, .9, 0>, <0,2.1,0> RB*.95 }
        Rotate_Around_Trans(ang, <0, 1, 0>)
        material { texture { matBomb2 } }
    } */


    cylinder { <0, 1, 0>, <0,2.2,0> RB*.9
        Rotate_Around_Trans(ang, <0, 1, 0>)
        material { texture { matWhite } }
    }
    
    text {
        ttf "timrom.ttf" "Tr" .1, 0
        pigment { rgb <0,0,0> }
        rotate <90,0,0>
        translate <-.4,2.25,-.4>
      Rotate_Around_Trans(ang, <0, 1, 0>)
    }
    
    
    //cylinder { <0, .9, 0> <0, 1.1, 0> RR
    //  material { texture { matBomb2 } } 
    //  Rotate_Around_Trans(ang, <0, 1, 0>)
    //}         

#end


